﻿using DevExpress.XtraReports.UI;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using JXC.Core;
using JXC.UI;
using JXC.WebApi.EntityExtend;
using SqlSugar;

namespace JXC.ReportPrint
{
    public partial class frmCGRKDPrint : DevExpress.XtraReports.UI.XtraReport
    {
        public CGRK data = null;
        private APIClient client = new APIClient();
        public frmCGRKDPrint()
        {
            InitializeComponent();
           
        }

        public frmCGRKDPrint(CGRK d):this()
        {
            data = d;
            BindData();
        }
        private void BindData()
        {
            xrLabel10.Text = data.m.GHSName;
            var ghs = client.GetGHSList().FirstOrDefault(m => m.GHSName.Equals(data.m.GHSName));
            xrLabel11.Text = ghs?.LXDZ;
            xrLabel12.Text = ghs?.LXDH;
            xrLabel13.Text = ghs?.LXR;
            xrLabel8.Text = data.m.Code;
            xrLabel9.Text = data.m.CodeTime.ToString();
            xrLabel16.Text = DateTime.Now.ToString();
            xrLabel15.Text = AppInfo.user.CZYName;
            xrLabel20.Text = $"{data.m.YFJE}";
            xrLabel18.Text = $"{data.m.Remark}";
            xrLabel22.Text = data.m.IsSH.Value ? "已审核" : "未审核";
            xrLabel24.Text = data.m.YFJE.ToString();
            xrLabel26.Text = data.m.SFJE.ToString();
            DataSet ds = new DataSet();
            var table = data.d.ListToDataTable();
            ds.Tables.Add(table);
            this.DataSource = ds;
            this.xrTableCell9.DataBindings.Add("Text", ds, "Id");
            this.xrTableCell10.DataBindings.Add("Text", ds, "SPName");
            this.xrTableCell11.DataBindings.Add("Text", ds, "CPGG");
            this.xrTableCell12.DataBindings.Add("Text", ds, "DW");
            this.xrTableCell13.DataBindings.Add("Text", ds, "SL");
            this.xrTableCell14.DataBindings.Add("Text", ds, "DJ");
            this.xrTableCell15.DataBindings.Add("Text", ds, "ZJE");
            this.xrTableCell16.DataBindings.Add("Text", ds, "BZ");

        }
    }
}
